package it.isa.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Corgile
 * @date 2022-02-27
 */
@RestController
@RequestMapping(value = "redis")
public class MyRedisOperations {
	@Autowired
	private StringRedisTemplate template;


	@GetMapping(value = "set")
	public String set() {
		ValueOperations<String, String> operations = this.template.opsForValue();
		operations.set("test", "人民的名义");
		return "success";
	}

	@GetMapping(value = "get")
	public String get() {
		ValueOperations<String, String> operations = this.template.opsForValue();
		String res = operations.get("test");
		System.out.println(res);
		return res;
	}
}
